﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Domain.Repositories;
using YAPACS.BusinessObjects.Managements.Exams;
using YAPACS.Organizations;

namespace YAPACS.RisServer.Controllers;

[Authorize]
[ApiController]
public class PatientFeatureController : AbpControllerBase
{
    private readonly ICurrentUserOrganization _currentUserOrganization;
    private readonly IRepository<PatientFeature, Guid> _patientFeatureRepository;

    public PatientFeatureController(ICurrentUserOrganization currentUserOrganization, IRepository<PatientFeature, Guid> patientFeatureRepository)
    {
        _currentUserOrganization = currentUserOrganization;
        _patientFeatureRepository = patientFeatureRepository;
    }

    [HttpGet("api/get-patient-features")]
    public async Task<IActionResult> GetPatientFeatures()
    {
        List<PatientFeature> list = await _patientFeatureRepository.GetListAsync(e => e.Department.Id == _currentUserOrganization.DepartmentId);
        var result = list.Select(e => new
        {
            Label = e.Name,
            Value = e.Id
        });
        return Ok(result);
    }
}
